import java.util.Arrays;
import java.util.LinkedList;
import java.util.Stack;

public class Mystack {
//    public static void main(String[] args) {
//        Stack<Integer> stack = new Stack<>();
//        stack.push(1);
//        stack.push(2);
//        stack.push(3);
//        stack.push(4);
//        stack.push(5);
//        int val = stack.peek();
//        System.out.println(val);
//        int val2=stack.pop();
//        System.out.println(val2);
//        val = stack.peek();
//        System.out.println(val);
//        stack.pop();
//        stack.pop();
//        stack.pop();
//        stack.pop();
//
//        boolean flg = stack.empty();
//        System.out.println(flg);
//    }
public int[] elem;
public int usedsize;
public static final int DEFAULT_SIZE = 10;
public  Mystack(){
    elem=new int[DEFAULT_SIZE];
}
public void push(int val){
    if (isFull()){
elem = Arrays.copyOf(elem,2*elem.length);
    }
    elem[usedsize]=val;
    usedsize++;
}
public boolean isFull(){
    if(usedsize==elem.length){
        return true;
    }
    return false;
}
public boolean empty(){
    if (usedsize==0){
        return true;
    }
    return false;
}

public int pop(){
    if (empty()){
         throw  new EmptyStackException(" 栈为空了！");
    }
    int OldVal = elem[usedsize-1];
    usedsize--;
    return OldVal;
}
public int peek(){
    if (empty()){
        throw  new EmptyStackException(" 栈为空了！");
    }
    int OldVal = elem[usedsize-1];
    return OldVal;
}
/*public void printList(ListNode head){
if (head == null){
    return;
}
if (head.next == null){
    System.out.println(head.val+" ");
    return;
}
printList(head.next);
    System.out.println(head.val+" ");*/


}
/*public void printList2(){
    Stack<ListNode> stack =new Stack<>();
    ListNode cur = head;
    while(cur != null){
        stack.push(cur);
        cur=cur.next;
    }
    while(!=stack.empty()){
        ListNdode top = stack.pop();
        System.out.println(top.val+" ");
    }
}*/
//}
